#include"Heap.h"

void test1()
{
	int arr[] = { 12,34,10,6,7,25,6,1,5 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int i = 0;
	HP hp;
	HeapInit(&hp);
	for (i = 0; i < sz; i++)
	{
		HeapPush(&hp, arr[i]);
	}
	HeapPrint(&hp);
	while (!HeapEmpty(&hp))
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}
	
	HeapDestroy(&hp);
}
void HeapSort(int* a, int n)
{
	int i = 0;
	HP hp;
	HeapInit(&hp);

	for (i = 0; i < n; i++)
	{
		HeapPush(&hp, a[i]);
	}
	i = 0;
	while (!HeapEmpty(&hp))
	{
		a[i++] = HeapTop(&hp);
		HeapPop(&hp);
	}
	HeapDestroy(&hp);
}

void test2()
{
	int arr[] = { 12,34,10,6,7,25,6,1,5 , 20, 66, 88, 14, 49, 3 };
	int i = 0;
	int sz = sizeof(arr) / sizeof(arr[0]);
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
	HeapSort(arr, sz);
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");

	
}
int main()
{
	//test1();
	test2();
	return 0;
}